/*
	Answer to Exercise 2-6, page 49
	Write a function setbits(x,p,n,y) that returns x with the n bits 
		that begin at position p set to the rightmost n bits of y, 
		leaving the other bits unchanged. 
*/
#include <stdio.h>


int main(){
	int x = 177;//1111 1111
	int p = 4, n = 4;
	int y = 0;
	y = setbits(x, p, n, y);
	printf("%d\n", y);
	return 0;
}

int setbits(int x,int p, int n, int y){
	int temp = 0;
	temp = x>>n & ~(~0<<n);
	y = temp;
	return y;
}




